package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

type MyReq struct {
	g.Meta `path:"/licenses/my" tags:"许可管理" method:"get" summary:"许可列表"`
	// TenantCode string `json:"tenantCode" description:"租户编码"`
	// AppCode string `json:"appCode"     description:"应用编码"`
	Status int `json:"status"       description:"状态:1正常2禁用3待审批"`
}
type MyRes struct {
	g.Meta `mime:"application/json"`
	Data   []MyLic `json:"data"`
}

type ListReq struct {
	g.Meta     `path:"/licenses" tags:"许可管理" method:"get" summary:"许可列表"`
	TenantCode string `json:"tenantCode" description:"租户编码"`
	TenantName string `json:"tenantName" description:"租户名称"`
	AppCode    string `json:"appCode"     description:"应用编码"`
	AppName    string `json:"appName"   description:"应用名称"`
	Status     int    `json:"status"       description:"状态:1正常2禁用3待审批"`
	Page       int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size       int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []LicRes `json:"data"`
	Total  int      `json:"total"`
}
type MyLic struct {
	Id        int64       `json:"id"           description:"主键"`
	AppCode   string      `json:"appCode"   description:"应用编码"`
	AppName   string      `json:"appName"   description:"应用名称"`
	AppDesc   string      `json:"appDesc"   description:"应用描述"`
	UserLimit int         `json:"userLimit"   description:"用户数"`
	ExpiredAt *gtime.Time `json:"expiredAt"  description:"过期日期"`
	Status    int         `json:"status"      description:"状态:1正常2禁用3待审批"`
}

type LicRes struct {
	Id         int64       `json:"id"           description:"主键"`
	TenantCode string      `json:"tenantCode" description:"租户编码"`
	TenantName string      `json:"tenantName" description:"租户名称"`
	AppCode    string      `json:"appCode"   description:"应用编码"`
	AppName    string      `json:"appName"   description:"应用名称"`
	AppDesc    string      `json:"appDesc"   description:"应用描述"`
	UserLimit  int         `json:"userLimit"   description:"用户数"`
	ExpiredAt  *gtime.Time `json:"expiredAt"  description:"过期日期"`
	Status     int         `json:"status"      description:"状态:1正常2禁用3待审批"`
}

type AddReq struct {
	g.Meta     `path:"/licenses" tags:"许可管理" method:"post" summary:"添加许可"`
	TenantCode string      `json:"tenantCode" v:"required" description:"租户编码"`
	AppCode    string      `json:"appCode"   v:"required"  description:"应用编码"`
	UserLimit  int         `json:"userLimit|min:1" v:"required"  description:"用户数"`
	ExpiredAt  *gtime.Time `json:"expiredAt" v:"required" description:"过期日期"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"组件Id"`
}

type UpdateReq struct {
	g.Meta    `path:"/licenses/{id}" tags:"许可管理" method:"put" summary:"更新许可"`
	Id        int64       `query:"id" v:"required|min:1"`
	ExpiredAt *gtime.Time `json:"expiredAt"  description:"过期日期"`
	Status    int         `json:"status"`
	UserLimit int         `json:"userLimit"   description:"用户数"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/licenses/{id}" tags:"许可管理" method:"delete" summary:"删除许可"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type StatusReq struct {
	g.Meta `path:"/licenses/status" tags:"许可管理" method:"get" summary:"许可状态列表"`
}
type StatusRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicStatus1 `json:"data"`
}

// input and output structs
type MyInput struct {
	TenantCode string `json:"tenantCode" description:"租户编码"`
	Status     int    `json:"status"       description:"状态:1正常2禁用3待审批"`
}
type MyOutput struct {
	Data []entity.License `json:"data" description:"应用列表"`
}
type ListInput struct {
	TenantCode string `json:"tenantCode" description:"租户编码"`
	AppCode    string `json:"appCode"     description:"应用编码"`
	Status     int    `json:"status"       description:"状态:1正常2禁用3待审批"`
	Page       int    `json:"page"        description:"页码"`
	Size       int    `json:"size"        description:"每页条数"`
}
type ListOutput struct {
	Data       []entity.License `json:"data" description:"应用列表"`
	TenantName string           `json:"tenantName" description:"租户名称"`
	AppName    string           `json:"appName"   description:"应用名称"`
	Total      int              `json:"total"        description:"总条数"`
}

type AddInput struct {
	do.License
}
type AddOutput struct {
	Id int64 `json:"id" description:"新增许可id"`
}

type UpdateInput struct {
	do.License
}

type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteInput struct {
	Id int64 `json:"id" v:"required#ID不能为空"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}
